	// #ifdef APP-NVUE
	var safeBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
	import { mapState, mapGetters } from 'vuex'
	// #endif
	import { SeckillCenterApi } from '@/api/serves.js'
	import { GoodsCenterApi } from '@/api/serves.js'
  export default {
    data() {
      return {
        id: '',                   // 秒杀id
				room_id: '',              // 专场id
				goods_id: '',             // 商品id
				details: {},              // 商品详情数据
				evaluation: {             // 评论 只显示一条
					total: '', 
					info: null,
				},
				address: ''
      }
    },
		computed: {
		  titleInfo() {
		    return {
		      goods_name: this.details.goods_name,
		      goods_sales: this.details.goods&&this.details.goods.goods_sales,
		      stock_num: this.details.stock_num,
		      address: this.details.merch_info && this.details.merch_info.address_city,
		    }
		  },
			priceInfo() {
				return {
					price: this.details.price,
					line_price: this.details.line_price,
					endTime: this.details.daojishi,
				}
			}
		},
    onLoad(options) {
      console.log(options);
			let obj = JSON.parse(options.info)
      this.id = obj.id
      this.room_id = obj.room_id
      this.goods_id = obj.goods_id
    },
		onShow() {
			if(this.id) this._initData()
		},
    methods: {
      _initData() {
       this._goodsdetail()  // 获取商品详情
       this._goodsEvaluate()  // 获取商品评价
			 if(this.isLogin) this.$store.dispatch('user/getUserCartsInfo',{ isGetAll: true })
      },
      // 获取商品详情
      _goodsdetail() {
				uni.showLoading()
        SeckillCenterApi.getDetaill({ id: this.id, room_id: this.room_id }).then(res => {
          console.log('获取商品详情', res);
					uni.hideLoading()
          if (res.code == 1) {
          	let result = res.data
						this.address = result.merch_info && result.merch_info.address_city || '未找到'
          	this.details = result
          }else {
						uni.showToast({	title: res.msg, icon:'fail'})
					}
        })
      },
			// 获取商品评价
			_goodsEvaluate() {
			  GoodsCenterApi.goods_comments({ goods_id: this.goods_id }).then(res => {
			    console.log('获取商品评价', res);
			    if (res.code == 1) {
						this.evaluation.total = res.count
						this.evaluation.info = res.data[0]
			    }
			  })
			},
			// 抢购
			seckill() {
				if(!this.isLogin) return this._login()
				SeckillCenterApi.goodsSeckill({ id: this.id, room_id: this.room_id }).then(res => {
				  console.log('抢购', res);
				  if (res.code == 1) {
						uni.showToast({	title: '抢购成功，请在我的秒杀中查看', icon:'none'})
						setTimeout(()=> {
							uni.navigateTo({
								url:'/pages/seckill/seckillMine/seckillMine'
							})
						}, 2000)
				  }else {
						uni.showToast({	title: res.msg, icon:'fail'})
					}
				})
			},
			// 跳转评论列表
			toDiscuss() {
				uni.navigateTo({
					url: '/pages/goodsDetail/goodsDiscuss/goodsDiscuss?itemId=' + this.itemId
				})
			},
    }
  }